package com.example.demo.controller;

import com.example.demo.entity.TableGoods;
import com.example.demo.entity.TableProduct;
import com.example.demo.service.ProductService;
import com.example.demo.service.GoodsService;
import com.example.demo.utils.PageDataList;
import com.example.demo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;//ProductService productService = new ProductService();
    @PostMapping("/list")
    public ResultUtil getList(@RequestBody TableGoods users) {
        PageDataList<TableGoods> resultList = goodsService.getList(users);
        ResultUtil resultUtil = new ResultUtil();
        if (resultList != null) {
            resultUtil.setResultCode("200");
            resultUtil.setResultMsg("请求成功");
            resultUtil.setResultData(resultList);
        } else {
            resultUtil.setResultCode("201");
            resultUtil.setResultMsg("请求失败");
        }
        return resultUtil;
    }
}
